
let $msg_container;
$(function () { 
    $msg_container = $('<div class="dialog_container">')
    $('body').append($msg_container);
})
function alertMsg(msg, opt) {
    opt = Object.assign({
        type: 'success',
        autoClose: true,
        delay: 2000,
        container: $msg_container,
        middle: true
    }, opt);
    let $msg = $('<div class="alert alert-' + opt.type + '">').text(msg);
    if (opt.middle) { 
        $msg.addClass('middle');
    }
    if (opt.autoClose) { 
        setTimeout(() => { 
            $msg.remove();
        }, opt.delay);
    }
    let $c = opt.container || $('body');
    $c.append($msg);
}